<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <script>

    function fac(n){
        let ans = 1;
        for(let i = 1;i <= n;++i)
            ans *= i;
        return ans;
    }
    function getFacSum(n){
        let ans = 0;
        for(let i = 1;i <= n;++i) ans  += fac(i);
        return ans;
    }
    let fac3 = fac(3);
    let fac3sum = getFacSum(3);
    console.log('3的阶为:'+fac3);
    console.log('3的阶乘和为: '+fac3sum);
    </script>
    
</body>
</html>